package day2;
class Animal{
    protected String name;
    protected int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void eat(){
        System.out.println("动物进食");
    }
    public void texing(){

    }
}
class cat extends Animal {
    //cat子类的构造方法
    public cat(String name, int age) {
        //先创建父类
        super(name, age);
    }
    //重写eat方法
    @Override
    public void eat() {
        System.out.println(this.name+"吃喵粮");;
    }
    public void texing(){
        System.out.println("小猫"+this.name+"正在喵喵叫");
    }
}

class bird extends Animal {
    public bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println("吃鸟粮");;
    }
    public void texing(){
        System.out.println("小鸟"+this.name+"正在飞");
    }
}
public class Demo1 {
    public static void main(String[] args) {
        cat cat1=new cat("猫猫",44);
        bird bird1=new bird("鸟鸟",88);
        //通过传参实现向上转型
        fun(cat1);
        System.out.println("--------");
        fun(bird1);

    }

    public static void fun(Animal animal){
        animal.eat();
        animal.texing();
    }
}
